package com.frank.oj.controller.msg;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.frank.oj.common.result.CommonResult;
import com.frank.oj.model.vo.SysMsgVO;
import com.frank.oj.service.msg.NoticeService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 系统信息、个人信息
 *
 * @author frank
 * @Date 2024/4/17
 */
@RestController
@RequestMapping("/api/msg")
public class NoticeController {

    @Resource
    private NoticeService noticeService;

    /**
     * 系统消息：未传id则全部删除，有id则删除指定信息
     */
    @RequestMapping(value = "/sys", method = RequestMethod.GET)
    @RequiresAuthentication
    public CommonResult<IPage<SysMsgVO>> getSysNotice(@RequestParam(value = "limit", required = false) Integer limit,
                                                      @RequestParam(value = "currentPage", required = false) Integer currentPage) {

        return noticeService.getSysNotice(limit, currentPage);
    }


    /**
     * 我的消息：如异常登录等
     */
    @RequestMapping(value = "/mine", method = RequestMethod.GET)
    @RequiresAuthentication
    public CommonResult<IPage<SysMsgVO>> getMineNotice(@RequestParam(value = "limit", required = false) Integer limit,
                                                       @RequestParam(value = "currentPage", required = false) Integer currentPage) {

        return noticeService.getMineNotice(limit, currentPage);
    }
}
